package cn.kgc.service.impl;

import cn.kgc.pojo.User;
import cn.kgc.dao.UserDao;
import cn.kgc.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 项目名：project0926
 * 创建人：君忆zm
 * 创建时间：2019/10/18-11:52
 */
@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private UserDao userDao;

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public User login(String username, String password) {
        return userDao.login(username, password);
    }

    @Override
    public List<User> userList() {
        return userDao.userList();
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int insertUser(User user) {
        return userDao.insertUser(user);
    }

    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public int deleteUser(int userId) {
        return userDao.deleteUser(userId);
    }
}
